// lib/main.dart
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:cesi/pages/cart_page.dart';
import 'package:cesi/pages/menu_page.dart';
// 1. 确保导入路径和文件名完全匹配
import 'package:cesi/pages/test.dart'; // 从 test.dart 改为 test_page.dart
import 'package:cesi/pages/welcome_page.dart';
import 'package:cesi/model/shop.dart';
import 'package:cesi/services/api_service.dart';
import 'package:cesi/model/coffee_model.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  // ApiService().init();
  runApp(
    MultiProvider(
      providers: [
        ChangeNotifierProvider(create: (context) => Shop()),
        ChangeNotifierProvider(create: (context) => CoffeeModel()),
      ],
      child: const MyApp(),
    ),
  );
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false, //右上角的debug图标去掉了，有需要再打开
      title: 'Coffee Shop',
      theme: ThemeData(primarySwatch: Colors.brown),
      // 2. 将 home 临时改为 TestPage 进行测试
      home: const WelcomePage(),
      routes: {
        '/welcomPage': (context) => const WelcomePage(),
        '/menuPage': (context) => const MenuPage(),
        '/cartPage': (context) => const CartPage(),
        // 如果你希望通过路由访问 TestPage，可以取消注释这一行
        '/testPage': (context) => const TestPage(),
      },
    );
  }
}
